package com.caow.androidktbase

import android.app.Application
import android.content.Context
import androidx.multidex.MultiDex
import com.alibaba.android.arouter.launcher.ARouter
import com.caow.androidktbase.module.myModule
import com.caow.baselibrary.GlobalConfig
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.context.startKoin
import org.koin.core.logger.Level


/**
 * @Author caow
 * 2022/11/24
 */
class App : Application() {

    override fun attachBaseContext(newBase: Context?) {
        super.attachBaseContext(newBase)
        MultiDex.install(this)
    }

    override fun onCreate() {
        super.onCreate()
        GlobalConfig.init(this, BuildConfig.DEBUG, "http://192.168.2.234:5005")

        // Koin初始化
        startKoin {
            androidLogger(Level.INFO)
            androidContext(this@App)
            modules(myModule)
        }

        if (BuildConfig.DEBUG){
            ARouter.openLog()
            ARouter.openDebug()
        }
        ARouter.init(this)
    }

    override fun onTerminate() {
        ARouter.getInstance().destroy()
        super.onTerminate()
    }
}